package cn.tudu.boot31.mapper;

import cn.tudu.boot31.entity.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductMapper {
    @Insert("insert into product values(null,#{title},#{price},#{saleCount})")
    void insert(Product product);
    @Select("select *from product")
    //单独这么写,类对象的属性名字,如果和数据库的字段名字不对应,会查询出来空值,所以需要加注解
    @Result(column = "sale_count",property = "saleCount")
    //column 是列字段对应的名称, property 是属性名称
    List<Product> select();
    @Delete("delete from product where id=#{id}")
    void delete(int id);
    @Update("update product set title=#{title},price=#{price},sale_count=#{saleCount} where id=#{id}")

    void update(Product product);
}
